<div class="container-fluid">

    <app-page-title title="Projects" [breadcrumbItems]="breadCrumbItems"></app-page-title>

    <div class="row">
        <div class="col-lg-12">
            <div class="card">
                <div class="card-body">
                    <h4 class="card-title mb-4">Create new project</h4>
                    <form class="needs-validation" (ngSubmit)="validSubmit()" [formGroup]="projectForm">
                        <div class="form-group">
                            <label for="firstname">Name</label>
                            <input type="text" class="form-control" id="firstname"
                                formControlName="name" placeholder="Add Project Title"
                                onfocus="this.placeholder = ''" onblur="this.placeholder = 'Add Project Title'"
                                [ngClass]="{'is-invalid': submit && form.name.errors}">
                            <div *ngIf="submit && form.name.errors" class="invalid-feedback">
                                <span *ngIf="form.name.errors.required">Required!</span>
                            </div>
                        </div>                        
                        <div class="form-group">
                            <label for="version">Version</label>
                            <input type="text" class="form-control" id="version"
                                formControlName="version" placeholder="Add Project Version"
                                onfocus="this.placeholder = ''" onblur="this.placeholder = 'Add Project Version'"
                                [ngClass]="{'is-invalid': submit && form.version.errors}">
                            <div *ngIf="submit && form.version.errors" class="invalid-feedback">
                                <span *ngIf="form.version.errors.required">Required!</span>
                            </div>
                        </div>     
                        <div class="form-group">
                            <label for="description">Description</label>
                            <textarea type="text" class="form-control" id="description"
                                formControlName="description" placeholder="Add Project Description"
                                onfocus="this.placeholder = ''" onblur="this.placeholder = 'Add Project Description'"
                                [ngClass]="{'is-invalid': submit && form.description.errors}" rows="20"></textarea>
                            <div *ngIf="submit && form.description.errors" class="invalid-feedback">
                                <span *ngIf="form.description.errors.required">Required!</span>
                            </div>
                        </div>   
                        <div class="text-right">
                            <button (click)="createProject()" class="btn btn-success mr-2" type="submit">Create</button>
                            <button [routerLink]="['/projects/manage']" class="btn btn-danger"
                                type="button">Cancel</button>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>

</div>